const app = getApp()
import {
  ShareFriends,
  userInfo
} from '../../config/https'
//分销信息
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: '',
    invitationCode: '',      //邀请码
    linklist: [
      {
        name: '银行卡',
        image: '/assets/images/bank_icon.png'
      },
      {
        name: '我要提现',
        image: '/assets/images/money_box.png'
      },
      {
        name: '佣金明细',
        image: '/assets/images/details_icon.png'
      },
      {
        name: '我要推广',
        image: '/assets/images/share_icon.png'
      },
      {
        name: '我的团队',
        image: '/assets/images/team_icon.png'
      }
    ]
  },
  getData(){
    ShareFriends({
      token: wx.getStorageSync('token')
    }).then(res => {
      if(res.code == 1){
        wx.setStorageSync('invitationCode', res.data.invitation_code)
      }
    })
  },
  getUserInfo(){
    userInfo({
      token: wx.getStorageSync('token')
    }).then(res => {
      if(res.code == 1){
        this.setData({
          userInfo: res.data
        })
      }
    })
  },
  goMoney(){
    wx.navigateTo({
      url: '/pages/withdraw/withdraw',
    })
  },
  Selectoption: function(e) {
    var name = e.currentTarget.dataset.name;
    var nav = '';
    if (name == '银行卡') {
      nav = '/pages/mybankcard/mybankcard'
    } 
    if (name == '我要提现') {
      nav = '/pages/withdraw/withdraw?type=1'
    }
    if (name == '佣金明细') {
      nav = '/pages/withdrawdetail/withdrawdetail?type=1'
    }
    if (name == '我要推广') {
      nav = '/pages/sharingPosters/sharingPosters'
    }
    if (name ==  '我的团队'){
      nav = '/pages/myteammate/myteammate'
    }
     
    wx.navigateTo({
      url: nav,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData()
    this.getUserInfo()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})